export default function (ele: HTMLElement, Upfn?: Function, downFn?: Function) {
  let StartY = 0, endY = 0
  ele.ontouchstart = (e) => {
    //事件的touches属性是一个数组，其中一个元素代表同一时刻的一个触控点，从而可以通过touches获取多点触控的每个触控点
    //由于我们只有一点触控，所以直接指向[0]
    let touch = e.touches[0]
    // var x = touch.clientX
    StartY = touch.clientY
  }
  ele.ontouchmove = (e) => {
    e.preventDefault()
  }
  ele.ontouchend = (e) => {
    let touch = e.changedTouches[0]
    endY = touch.clientY
    const moveDistance = endY - StartY
    if (moveDistance > 100 && downFn) {
      downFn()
    }
    if (moveDistance < -100 && Upfn) {
      Upfn()
    }
  }
}